//
//  TableFourViewController.m
//  Advertisement
//
//  Created by mac on 16/4/5.
//  Copyright © 2016年 Appcoda. All rights reserved.
//

#import "TableFourViewController.h"
#import "netWork.h"
#import "MAin.h"
@interface TableFourViewController ()
{
    NSString * _str1;
    NSString * _str2;
}
@end

@implementation TableFourViewController

- (void)viewDidLoad {
    [super viewDidLoad];
     self.title = self.myTitle;
    _tableViewFour = [[UITableView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    _tableViewFour.delegate = self;
    _tableViewFour.dataSource = self;
    _tableViewFour.rowHeight = 80;
    [self.view addSubview:_tableViewFour];
    _userDefault3 = [NSUserDefaults standardUserDefaults];
    NSString * intNumber =[NSString stringWithFormat:@"%@",[_userDefault3 valueForKey:@"row3"]];
    int a;
    a = [intNumber intValue];
    NSLog(@"++++++++++++++%d",a);
    _titleTwoArray = [[NSMutableArray alloc]init];
    [netWork scroll:^(NSArray *arr) {
        [_titleTwoArray setArray:arr];
        [_tableViewFour reloadData];
    } type:[NSString stringWithFormat:@"app_loadType?id=%d",a]];

    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _titleTwoArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *UIimage = @"Identifer";
    
    
    //为节省内存，获取之前的存在的tableViewCell
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:UIimage];
    MAin * main =[_titleTwoArray objectAtIndex:indexPath.row];
    if( cell == nil ){
        //创建UITableViewCell对象，设置行的样式和别名
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:UIimage];
        cell.textLabel.text = main.name;
        cell.textLabel.font = [UIFont systemFontOfSize:18];
        cell.textLabel.textColor =[UIColor blueColor];
        
    }
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    TableFiveViewController *vc = [[TableFiveViewController alloc]init];
    vc.hidesBottomBarWhenPushed = YES;
    NSLog(@"%ld", indexPath.row);
    NSLog(@"%ld", self.index);
    if (indexPath.row == 0) {
        vc.string  = @"http://47.88.76.185/John2.html";
    }else if (indexPath.row == 1){
        vc.string = @"http://47.88.76.185/Shokley.html" ;
    }else if (indexPath.row == 2){
        vc.string =@"http://47.88.76.185/Stanford_University.html" ;
    }else if (indexPath.row == 3){
        vc.string = @"http://47.88.76.185/Steve_Wozniak.html";
    }else if (indexPath.row == 4){
        vc.string = @"http://47.88.76.185/sx/html2/FEP.html";
    }else if (indexPath.row == 5){
        vc.string = @"http://47.88.76.185/terman.html";
    }else if (indexPath.row == 6){
        vc.string = @"http://47.88.76.185/sx/htm/cable.html";
    }else if (indexPath.row == 7){
        vc.string = @"http://47.88.76.185/sx/htm/Dieletric.html";
    }else if (indexPath.row == 8){
        vc.string = @"http://47.88.76.185/sx/htm/Metal.html";
    }else if (indexPath.row == 9){
        vc.string = @"http://47.88.76.185/sx/htm/SqlServer.html";
    }else if (indexPath.row == 10){
        vc.string = @"http://47.88.76.185/sx/htm/Switch.html";//http://47.88.76.185/sx/html2/电子元器件.html
    }else if (indexPath.row == 11){
        vc.string = @"http://47.88.76.185/sx/html/Arthur.html";
    }else if (indexPath.row == 12){
        vc.string = @"http://47.88.76.185/sx/htm/Switch.html";
    }else if (indexPath.row == 13){
        vc.string = @"http://47.88.76.185/sx/html/DMOS.html";
    }else if (indexPath.row == 14){
        vc.string = @"http://47.88.76.185/sx/html/DRAMS.html";//http://47.88.76.185/sx/html2/电子元器件.html
    }else{
        vc.string = @"http://47.88.76.185/sx/htm/Metal.html";//http://47.88.76.185/sx/html2/硅晶片.html
    }
    
    
    [self.navigationController pushViewController:vc animated:YES];

    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
